﻿using supermarket.method;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace supermarket
{
    public partial class supupdatenumber : Form
    {
        Classuser us = new Classuser();
        public supupdatenumber()
        {
            InitializeComponent();
        }
        private void supupdatenumber_Load(object sender, EventArgs e)
        {
            us.userandcom(comusername);
        }
        //清空
        private void button1_Click(object sender, EventArgs e)
        {
            txtnewnumber.Text = "";
            txtnnumber.Text = "";
            comusername.Text = "";
        }
        //确定
        private void label2_Click(object sender, EventArgs e)
        {
            
        }
        //取消
        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            //判断手机号
            string number = this.txtnnumber.Text;
            if (!CommonHelper.IsValidPhoneNumber(number))
            {
                MessageBox.Show("请输入正确的手机号");
                return;
            }

            if (txtnnumber.Text != txtnewnumber.Text)
            {
                MessageBox.Show("两次输入的手机号不一致！", "提示");
            }
            else
            {
                if (us.upsupnumber(comusername.Text, txtnnumber.Text) == 1)       //如果两次输入的新手机号一致
                {
                    MessageBox.Show(comusername.Text + "会员手机号修改成功！", "提示");
                }
                else
                {
                    MessageBox.Show(comusername.Text + "会员手机号修改失败！", "提示");
                }
            }
        }
    }
}
